package com.ft.turorial.consumer;

import com.ft.turorial.SpringBootStreamKafkaConsumerConsumerApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2016/12/8
 * \* Time: 13:36
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
@EnableBinding(Sink.class)
public class LoggingSink {
    private static Logger logger = LoggerFactory.getLogger(SpringBootStreamKafkaConsumerConsumerApplication.class);

    @StreamListener(Sink.INPUT)
    public void loggerSink(SinkTimeInfo sinkTimeInfo) {
        logger.info("Received: " + sinkTimeInfo.toString());
    }

    public static class SinkTimeInfo{

        private String time;
        private String label;

        public String getTime() {
            return time;
        }

        public void setTime(String time) {
            this.time = time;
        }

        public void setSinkLabel(String label) {
            this.label = label;
        }

        public String getLabel() {
            return label;
        }

        @Override
        public String toString() {
            return "SinkTimeInfo [time=" + time + ", label=" + label + "]";
        }

    }
}
